package stz.flash.option.app;

import stz.flash.Info;
import stz.flash.option.PersistentData;
import stz.flash.string.OptionString;
import blackberry.util.hotkey.DjHotkey;


public class HomeScreenHotkeyOption {

	private static HomeScreenHotkeyOption instance = new HomeScreenHotkeyOption(); 
	private PersistentData data = PersistentData.getPersistentDatabase();
	
	private HomeScreenHotkeyOption() {
	}
	
	public static HomeScreenHotkeyOption getIns(){
		return instance;
	}
	
	public String getHomeScreenHotkey() {
		return data.getHomeScreenHotkey();
	}
	public void setHomeScreenHotkey(String hotkey) {
		data.setHomeScreenHotkey(hotkey);
		updateHomeScreenHotkeyWithPersistentData();
	}
	
	public void updateHomeScreenHotkeyWithPersistentData() {
		
		String hotkey = getHomeScreenHotkey();
		
		if (hotkey.equals(OptionString.NONE))
			DjHotkey.replaceCurrentAppHotkey('\u0000');
		
		else if (hotkey.equals(Info.KEY_SPACE))
			DjHotkey.replaceCurrentAppHotkey('\u0020');
		
		else 
			DjHotkey.replaceCurrentAppHotkey(hotkey);
	}
}
